<!-- 屏蔽雇主 -->
<template>
	<view class="">
		<view class="searchcss">
			<uni-search-bar @confirm="search" placeholder='请输入雇主名称' bgColor='#ffffff' v-model="from.search" radius="33"></uni-search-bar>
		</view>
		<view class="list-box">
			<view class="item-box" v-for="(item,index) in list" :kye="index">
				<view class="name">
					{{item}}
				</view>
				<view class="bnt-box" @click="shield(index)">
					屏蔽
				</view>
			</view>
		</view>
		<!-- <Empty v-if="list.length == 0 && show" text='暂无公司信息' /> -->
	</view>
</template>

<script>
	import * as user from '@/api/user.js'
	export default {
		data() {
			return {
				placeholder: '请输入雇主名称',
				from: {
					search:''
				},
				list: [],
				show: false
			}
		},
		onLoad() {
			// this.search()
		},
		onReachBottom() {
		},
		onPageScroll(e) {
		},
		onPullDownRefresh() {
			if(this.from.search) {
				this.search()
			}
			uni.stopPullDownRefresh();
		},
		methods: {
			//关键词搜索
			search() {
				user.getCompanyList(this.from).then(res=>{
					this.list = res.data
					if(this.list.data.length == 0) {	
						this.show = true
					} else {
						this.show = false
					}
				})
			},
			// 屏蔽雇主
			shield(e) {
					uni.showModal({
					    title: '提示',
					    content: '确定屏蔽该雇主吗?',
					    success:(res)=> {
							if (res.confirm) {
								user.shield({id:e}).then(res=>{
								this.$tools.toast('屏蔽雇主成功!');
									setTimeout(res=>{
										uni.navigateBack({
											data:1
										})
									},500)
								})
							}
					    }
					})
			}
		}
	}
</script>

<style scoped lang="scss">
	.searchcss {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		background-color: #f3f4f6;
	}
	.list-box {
		margin-top: 120rpx;
		background: #ffffff;
		padding: 0rpx 15rpx 0rpx 15rpx;
		.item-box {
			border-top: 2rpx solid #f4f4f4 ;
			display: flex;
			padding: 30rpx;
			align-items: center;
			.name {
				width: 600rpx;
			}
			.bnt-box {
				width: 100rpx;
				height: 50rpx;
				background: #FF6600;
				margin-left: auto;
				border-radius: 15rpx;
				text-align: center;
				line-height: 50rpx;
				color: #ffffff;
			}
		}
	}
</style>
